package cn.cj.erp.common.vo.login;

import cn.cj.erp.common.utils.encrypt.AesUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * 请求登录
 *
 * @author chenjian
 */
@Data
public class LoginVo {
    /** 用户名 */
    @NotBlank(message = "用户名不能为空")
    private String username;

    /** 密码 */
    @NotBlank(message = "密码不能为空")
    private String password;

    /** 验证码 */
    @NotBlank(message = "验证码不能为空")
    private String code;

    /** uuid */
    @NotBlank(message = "uuid不能为空")
    private String uuid;

    public void decrypt() {
        this.username = AesUtil.decrypt(StrUtil.replace(this.username, " ", "+"),
                this.uuid.substring(16));
        this.password = AesUtil.decrypt(StrUtil.replace(this.password, " ", "+"),
                this.uuid.substring(16));
    }
}
